/**
 * Application Application.java
 */

package CCT220_Aula19_Exercicio04_13106;


import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;


/**
 * </br>******************************
 * </br>Project: CCT220
 * </br>Package: CCT220_Aula19_Exercicio04_13106
 * </br>Class: Application
 * </br>Last Change: 28/10/2011 20:52:35 by marcel
 * </br>Description:
 * </br>******************************</br>
 * 
 * @author marcel
 * @author 13106
 * 
 */

public class Application {
	private JSlider      js;
	private JProgressBar jpbh;
	private JProgressBar jpbv;


	public Application() {

		this.startComponents();
		JFrame jf = new JFrame("Marcel M. Grilo - 13106");
		jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jf.setLayout(new GridLayout(3, 1, 5, 5));
		jf.setSize(500, 500);
		jf.add(js);
		jf.add(jpbh);
		jf.add(jpbv);
		jf.setVisible(true);
	}


	private void startComponents() {

		js = new JSlider(0, 100, 0);
		jpbh = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
		jpbh.setString("Horizontal 0%");
		jpbh.setStringPainted(true);
		jpbv = new JProgressBar(JProgressBar.VERTICAL, 0, 100);
		jpbv.setString("Vertical 0%");
		jpbv.setStringPainted(true);

		js.addChangeListener(new ChangeListener() {
			@Override
			public void stateChanged(ChangeEvent e) {

				jpbv.setString("Vertical " + js.getValue() + "%");
				jpbh.setString("Horizontal " + js.getValue() + "%");
				jpbh.setValue(js.getValue());
				jpbv.setValue(js.getValue());
			}
		});

	}


	public static void main(String[] args) {

		new Application();
	}
}
